package org.example.springbook.enums;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-07-15
 * Time: 13:24
 */
public enum BookStatusEnum {
    DELETED(0, "删除"),
    NORMAL(1, "可借阅"),
    FORBIDDEN(2, "不可借阅");

    private Integer code;
    private String status;


    BookStatusEnum(Integer code, String status) {
        this.status = status;
        this.code = code;
    }

    public static BookStatusEnum getNameByCode(int code) {
        return switch (code) {
            case 0 -> BookStatusEnum.DELETED;
            case 1 -> BookStatusEnum.NORMAL;
            default -> BookStatusEnum.FORBIDDEN;
        };
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
